package cn.tedu.demo;

import org.junit.Test;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

//@Component注解表示当组件扫描机制扫描到这个类时
//这个类会自动实例化对象保存到Spring容器中
//id默认是类名首字母小写的状态既hero
@Component
//原型模式注解如下
@Scope("prototype")
//@Controller
//@Service
//@Repository
public class Hero {
    private int hp=200;// 生命值
    private String desc="无敌猪脚";// 描述

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    @Override
    public String toString() {
        return "Hero{" +
                "hp=" + hp +
                ", desc='" + desc + '\'' +
                '}';
    }
}
